package cn.audit.service.operation;

import cn.audit.bean.dto.UserCorrelation;
import cn.audit.bean.dto.zuzhangzhengshuai;
import cn.audit.bean.pojo.AuditPlan;
import cn.audit.repository.operation.AuditPlanRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author fei人类
 * @date 2019/05/20
 */
@Service
public class AuditPlanService {
    @Resource
    private AuditPlanRepository auditPlanRepository;

    public List<UserCorrelation> findAll() {
        return auditPlanRepository.findPlanItemAll();
    }

    public List<UserCorrelation> findPlanStatus() {
        return auditPlanRepository.findPlanStatus();
    }

    public AuditPlan findAuditPlanById(Long id) {
        return auditPlanRepository.findAuditPlanById(id);
    }

    @Transactional(rollbackFor = Exception.class)
    public void updateAuditPlanStatus(Long status, Long id) {
        auditPlanRepository.updateAuditPlanStatus(status, id);
    }

    public void saveAudit(AuditPlan auditPlan){
        auditPlanRepository.save(auditPlan);
    }

    @Transactional
    public void updateAudit(Long id){
        auditPlanRepository.updateAuditPlanStatus((long)2,id);
    }

    @Transactional
    public void deleteAudit(Long id){
        auditPlanRepository.updateAuditPlanStatus((long)0,id);
    }

    public zuzhangzhengshuai findId(Long id) {
        return auditPlanRepository.findId(id);
    }

    public List<zuzhangzhengshuai> bbb() {
        return auditPlanRepository.bbb();
    }

}
